package com.lujieni.nio.c1;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;

public class TestFenSanRead {

    public static void main(String[] args) {
        try (FileChannel channel = new RandomAccessFile("words.txt", "r").getChannel()) {
            ByteBuffer a1 = ByteBuffer.allocate(3);
            ByteBuffer a2 = ByteBuffer.allocate(3);
            ByteBuffer a3 = ByteBuffer.allocate(3);
            channel.read(new ByteBuffer[]{a1, a2, a3});
            a1.flip();
            a2.flip();
            a3.flip();
            System.out.println(StandardCharsets.UTF_8.decode(a1));
            System.out.println(StandardCharsets.UTF_8.decode(a2));
            System.out.println(StandardCharsets.UTF_8.decode(a3));
        } catch (IOException e) {

        }
    }
}
